package com.zzh.ideas.web.system.handler;

import sun.misc.Signal;
import sun.misc.SignalHandler;

/**
 * description: <br>
 * createTime: 2019/7/1211:59 <br>
 *
 * @author zzh
 */
public class DebugSignalHandler  implements SignalHandler
{
    public static void listenTo(String name) {
        Signal signal = new Signal(name);
        Signal.handle(signal, new DebugSignalHandler());
    }

    public void handle(Signal signal) {
        System.out.println("Signal: " + signal);
        if (signal.toString().trim().equals("SIGTERM")) {
            System.out.println("SIGTERM raised, terminating...");
            System.exit(1);
        }
    }
}
